import React from 'react';
import ReactDOM from 'react-dom';
import * as serviceWorker from './serviceWorker';



//函数式组件

function Childcom(props){
  let title = <h2>我是标题</h2>
  let weather = props.weather
 
  //条件判断
  let isGo =  weather == '下雨'?'不出门':'出门'

  return (
    <div>
      <h1>函数式组件helloword</h1>
      {title}

      <div>
        是否出门?
        <span>{isGo}</span>
      </div>
    </div>
  )
}

//类组件的定义

class HelloWord extends React.Component{
  
  render(){
    console.log(this);
    return (
     
      <div>
        <h1>类组件helloword</h1>
        <Childcom/>
    <h1>今天:{this.props.weather}</h1>
      </div>
    )
  }
}




// ReactDOM.render(
  // <Childcom weather="下雨"/>,
  // document.getElementById('root')
// )


ReactDOM.render(
  <HelloWord weather="下雨"/>,
  document.getElementById('root')
)
// 
// 


// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
